using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;

/// <summary>
/// Summary description for FilePathHelper
/// </summary>
public class MyFilePathHelper {
    public static string GetImageURL(string imageFName) {
        return ConfigurationManager.AppSettings["ImagesFolder"] + imageFName;
    }

    public static string WebsiteUrl() {
        return ConfigurationManager.AppSettings["WebsiteUrl"];
    }

    public static string SocialImagesFolder() {
        return ConfigurationManager.AppSettings["SocialImagesFolder"];
    }

    public static string ImageResourceUrlPrefix() {
        return ConfigurationManager.AppSettings["ImageResourceUrlPrefix"];
    }

    public static string GetImageBrowserURL() {
        return ConfigurationManager.AppSettings["ImageBrowserURL"];
    }

    public static string GetImageFolderURL(Page currentPage) {
        return UIPage.AppPath+ ConfigurationManager.AppSettings["ImagesFolder"];
    }

    public static string GetImageFolderURL_Saving(Page currentPage) {
        string rootPath = currentPage.Server.MapPath(@"~");
        string imagePath = rootPath +  ConfigurationManager.AppSettings["ImagesSubPath"];
        return imagePath;
        //return ConfigurationManager.AppSettings["ImagesFolder"];
    }

    public static string GetLinkBrowserURL() {
        return ConfigurationManager.AppSettings["LinkBrowserURL"];
    }

    public static string TruncateLastFolder(string fullFolder) {
        int pos = fullFolder.LastIndexOf(@"\");
        if (pos > 0) {
            return fullFolder.Substring(0, fullFolder.Substring(0, pos).LastIndexOf(@"\"));
        } else {
            return fullFolder;
        }
    }
    public static string GetTimeStamp() {
        DateTime now = DateTime.Now;
        string result = now.ToString("yyyyMMddhhmmss");
        return result;
    }
    public static string AppendTimeStamp(string fileName) {
        int pos = fileName.LastIndexOf(".");
        if (pos > 0) {
            return fileName.Insert(pos, GetTimeStamp());
        } else {
            return fileName + GetTimeStamp();
        }
    }

    public static void DeleteResource(string path, string resourceName) {
       
            string fileName = path +  resourceName;
            //call delete file
        
           
                File.Delete(fileName);
           
        } 
   
}
